Why a LSP?
- Large number of IDEs, why I need to rewrite a compiler several times for each different languages/environment?
- a good principle could be (good enough approach):
- define generic editing features
-
use a language specific configuration using an external service
-
is possible provide a correct separation of responsibilities:
- editor developers are focused on the editor part (provide plugin, new functionality)
-
language developers are focused on the language support to provide for all the IDEs
-
any developer - any language - any tool
How it works on hi-level
- the ide will connect to the language server
- the language server is a separate component (usually a background process)
- the communication between two components is realized using JSON RPC messages
LSP Java implementation = LSP4J
- Java implementation of LSP
- JSON messages communication, result wrapped in a object with methods and so on
- APIs for implement LSP (interfaces)
- client/server endpoints
Workthough example
||define this snippet with gist
-
client invocation:
-
JSON RPC:
Manage a LSP
- use a defined SDK and implement the specifications
- here the available SDKs: https://microsoft.github.io/language-server-protocol/implementors/sdks/
- here the specification rules: https://microsoft.github.io/language-server-protocol/specification
- use an already defined LSP servers to integrate in the IDE
- more info at https://microsoft.github.io/language-server-protocol/implementors/servers/